package emergence.game.sfx;

import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;

import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;
import javax.swing.JOptionPane;

public class LoopSound {

    public static void main(String args[]) {
        Clip clip;
		try {
			clip = AudioSystem.getClip();
			Path curPath = Paths.get("");
			String path = curPath.toAbsolutePath().toString();
			String filePath = path + "\\Data\\TitleMusic.wav";
			AudioInputStream ais = AudioSystem.getAudioInputStream(new File(filePath));
			clip.open(ais);
	        clip.loop(Clip.LOOP_CONTINUOUSLY);
//	        clip.start();
		} catch (LineUnavailableException e) {
			JOptionPane.showMessageDialog(null, e);
			e.printStackTrace();
		} catch (UnsupportedAudioFileException e) {
			JOptionPane.showMessageDialog(null, e);
			e.printStackTrace();
		} catch (IOException e) {
			JOptionPane.showMessageDialog(null, e);
			e.printStackTrace();
		} catch (Exception e) {
			JOptionPane.showMessageDialog(null, e);
			e.printStackTrace();
		}
    }
}
